Fix some memory problem that report by valgrind#1886
Merged
vkareh merged 4 commits intomate-desktop:masterfrom May 5, 2026
Merged
Fix some memory problem that report by valgrind#1886vkareh merged 4 commits intomate-desktop:masterfrom
vkareh merged 4 commits intomate-desktop:masterfrom
Conversation
cwendling
reviewed
Apr 23, 2026
cwendling
reviewed
Apr 23, 2026
cwendling
reviewed
Apr 23, 2026
Destroy popup menu in finalize function since it's a floating widget without parent. Also nullify borrowed pointers to avoid dangling references.
The lookup key used size * scale while the insert key used original size, causing cache misses and unbounded cache growth.
Valgrind shows: ==2022== 40,416 bytes in 1,010 blocks are still reachable in loss record 1,771 of 1,825 ==2022== at 0x877258A: g_type_create_instance (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x87561FC: ??? (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x8758120: g_object_new_valist (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x8758468: g_object_new (in /usr/lib64/libgobject-2.0.so.0.5600.1) ==2022== by 0x468B2C: caja_notes_viewer_init (caja-notes-viewer.c:339) gtk_text_view_new_with_buffer() adds a reference to the text buffer, so we need to unref it after to transfer ownership.
Valgrind shows: ==2022== 129,024 bytes in 504 blocks are still reachable in loss record 1,798 of 1,825 ==2022== at 0x4C29BC3: malloc (vg_replace_malloc.c:299) ==2022== by 0xDDD860A: ??? (in /usr/lib64/libpixman-1.so.0.34.0) ==2022== by 0xDD9F719: ??? (in /usr/lib64/libpixman-1.so.0.34.0) ==2022== by 0x797DF88: ??? (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x797EBE6: ??? (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x797EC7B: ??? (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x795224C: cairo_surface_create_similar_image (in /usr/lib64/libcairo.so.2.11512.0) ==2022== by 0x6B88AB0: gdk_window_create_similar_image_surface (in /usr/lib64/libgdk-3.so.0.2200.30) ==2022== by 0x6B61FDF: gdk_cairo_surface_create_from_pixbuf (in /usr/lib64/libgdk-3.so.0.2200.30) ==2022== by 0x5157D2: caja_icon_info_get_surface_nodefault_at_size (caja-icon-info.c:576) ==2022== by 0x52830A: get_action_icon (caja-ui-utilities.c:160) ==2022== by 0x528691: caja_action_from_menu_item (caja-ui-utilities.c:189) ==2022== by 0x4853EE: add_extension_menu_items (caja-window-menus.c:1097) ==2022== by 0x485DEC: caja_window_load_extension_menus (caja-window-menus.c:1174) gtk_action_group_add_action_with_accel() adds a reference to the action, so we need to unref it after. The menu object is obtained via g_object_get() which returns a full reference that must be unreleased.
vkareh
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Valgrind report was run against caja-1.22.0, but I found that this problem is not fixed in the latest version.